package com.zhangfei.stream;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class MapTest {
    public static void main(String[] args) {
        //初始化学生数据并转成list
        List<Student> students = Arrays.asList(
                new Student(1, "张三", 25),
                new Student(3, "李四", 32),
                new Student(4, "王五", 40),
                new Student(5, "赵六", 29));
        mapStudent(students);
    }

    public static void mapStudent(List<Student> students) {
        List<String> stringList = students.stream()
                .map(student -> {
                    return student.getName();
                })
                .collect(Collectors.toList());
        System.out.println(stringList);
    }
}
